import { Injector, Input } from '@angular/core'
import { toBoolean } from 'ng-zorro-antd'

import { AbstractCustomSelectComponent } from './custom-select.component'

export abstract class AbstractCustomMultipleSelectComponent<T, P = {}> extends AbstractCustomSelectComponent<T, P> {
  constructor(public injector: Injector) {
    super(injector)
  }

  private _multiple = false
  mode = 'default'

  @Input()
  set value(value: T | T[]) {
    this._value = value
    this.notifyValueChange()
  }

  get value(): T | T[] {
    return this._value
  }

  @Input()
  set multiple(value: boolean) {
    this._multiple = toBoolean(value)
    this.mode = this._multiple ? 'multiple' : 'default'
  }

  get multiple(): boolean {
    return this._multiple
  }
}
